﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Toolkit.Web.ViewComponents.DataGrid
{
    public interface IReadOnlyDataGridColumnSettings
    {
        string Key
        {
            get;
        }

        int? Width
        {
            get;
        }

        int? Index
        {
            get;
        }

        bool IsVisible
        {
            get;
        }

        DataExpression SortExpression
        {
            get;
        }

        bool EnableWordWrap
        {
            get;
        }

        bool EnableMenu
        {
            get;
        }

        bool EnableResizing
        {
            get;
        }

        bool EnableSorting
        {
            get;
        }

        bool EnableHidingAndShowing
        {
            get;
        }

        bool EnableEditing
        {
            get;
        }

        string HorizontalAlignment
        {
            get;
        }

        bool LockPositionLeft
        {
            get;
        }
    }

    public sealed class DataGridColumnSettings : IReadOnlyDataGridColumnSettings
    {
        public DataGridColumnSettings(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException("key");
            }

            IsVisible = true;
            Key = key;
            SortExpression = new DataExpression(Key);
        }

        public string Key
        {
            get;
            private set;
        }

        public int? Width
        {
            get;
            set;
        }

        public int? Index
        {
            get;
            set;
        }

        public int? RenderedIndex
        {
            get;
            set;
        }

        public bool IsVisible
        {
            get;
            set;
        }

        public DataExpression SortExpression
        {
            get;
            set;
        }

        public bool EnableWordWrap
        {
            get;
            set;
        }

        public bool EnableMenu
        {
            get;
            set;
        }

        public bool EnableResizing
        {
            get;
            set;
        }

        public bool EnableSorting
        {
            get;
            set;
        }

        public bool EnableHidingAndShowing
        {
            get;
            set;
        }

        public bool EnableEditing
        {
            get;
            set;
        }

        public string HorizontalAlignment
        {
            get;
            set;
        }

        public bool LockPositionLeft
        {
            get;
            set;
        }
    }
}
